/**
 * Created by yuhuan on 2018/8/15 14:40.
 */
define(function () {

    var self,
        app = win.app,
        searchData = {
            keyword: ''
        },
        pageParameters
    ;

    var gwaq553 = app.Module.extend({

        init: function () {
            self = this;
            self._super({
                _refreshAutoInit: true,
                _readyBefore: function () {
                    pageParameters = self._pageParameters;
                }
                // 默认的id和data 如果如同以下设置，在这里可以省略不写
                // _search: {
                //     id: 'searchDiv',
                //     data: {
                //         keyword: ''
                //     }
                // }
            }, win);
        },
        _initRefresh: function () { // 实例化刷新组件
            if (self._refreshIds.length == 0) {
                self._refreshIds = ['scroll1'];
            }
            this._super(win);
        },
        _refreshCb: function (obj) {// 刷新组件回调函授
            var _super = this._super;
            app.ajax({
                xurl: "api/wx/gwaq553/getGwaq553List",
                xdata: {
                    page:obj.page+1,
                    limit: obj.limit,
                    keyword: searchData.keyword,
                    GWBH031: pageParameters.GWBH031?pageParameters.GWBH031:''
                },
                cb: function (result) {
                    if (result.ok) {
                        var data = result.data;
                        _super({
                            obj: obj,
                            data: data.data,
                            nodata: '无商机信息...'
                        });
                    }
                }
            });
        },
        _search: function (data) {
            searchData.keyword = data.keyword.trim();
            self._refresh();
        },
        _ready: function () { // dom载入完成后执行

            Vue.component('sjmxitem', {
                template: app.getByid(doc, 'sjmxitem-template'),
                props: {
                    model: Array
                },
                methods: {
                    open: function (item) {
                        app.openPage({
                            src: 'gwaq553/gwaq553-info.html',
                            argsKey: 'gwaqinfo_page',
                            args: {
                                item: app.cloneJSON(item),
                                cb: function () {
                                    self._refresh();
                                }
                            }
                        });
                    }
                }
            });
        },
        _lazy: function () { // 延迟300ms加载
            this._super();
        }
    });

    new gwaq553();

});